package com.mapbased.wfw.ws;

import java.io.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: mapbased.com</p>
 *
 * @author chy_hs(Baily)
 * @version 1.0
 */
public class WSResult
    implements Serializable
{
    public static final byte OK=1;


    public static final byte ERROR= -1;

    private byte status=1;
    private java.io.Serializable result;
    public WSResult(byte status,Object result)
    {
        this.status=status;
        this.result=(Serializable)result;
    }

    public static WSResult okResult(Object result)
    {
        WSResult r=new WSResult(OK,result);
        return r;
    }

    public static WSResult errorResult(Object result)
    {
        WSResult r=new WSResult(ERROR,result);
        return r;
    }

    public String getErrorMsg()
    {
        if(OK == this.status)
        {
            return "No Error.";
        }

        if(this.result != null)
        {
            return this.result.toString();
        }
        if(this.getStatus() == this.ERROR)
        {
            return "Unknown error from server";
        }

        return "Unknown";
    }

    public boolean isOK()
    {
        return status == OK;
    }

    public Object getResult()
    {
        return result;
    }

    public byte getStatus()
    {
        return status;
    }

}
